Skip to content

[skip-changelog] Handle errors that occur during reset #2183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2023

Conversation

MatteoPologruto
Copy link
Contributor

@MatteoPologruto MatteoPologruto commented May 23, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Code imperfection fix

What is the current behavior?

Trying to upload a sketch when the serial port is busy correctly fails, but the error is displayed as simple output text.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create

{
  "instance": {
    "id": 1
  }
}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "fqbn": "arduino:mbed_nano:nanorp2040connect", "sketch_path": "C:/Users/m.pologruto/Documents/Arduino/sketch_simple", "port": {"address": "COM3", "protocol": "serial"}, "verbose": true}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Upload

{
  "outStream": "UGVyZm9ybWluZyAxMjAwLWJwcyB0b3VjaCByZXNldCBvbiBzZXJpYWwgcG9ydCBDT00zCg=="
}
{
  "outStream": "IkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcQXJkdWlubzE1XHBhY2thZ2VzXGFyZHVpbm9cdG9vbHNccnAyMDQwdG9vbHNcMS4wLjYvcnAyMDQwbG9hZCIgLXYgLUQgIkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcVGVtcFxhcmR1aW5vXHNrZXRjaGVzXEY1NEYxRUNFMTE2RTgzMTk2NzJBMTcyM0QzOUMwOUYwL3NrZXRjaF9zaW1wbGUuaW5vLmVsZiIKcnAyMDQwbG9hZCAxLjAuNiAtIGNvbXBpbGVkIHdpdGggZ28xLjE2LjIKLg=="
}
ERROR:
  Code: Internal
  Message: Failed uploading: uploading error: exit status 1
CALLED: /cc.arduino.cli.commands.v1.ArduinoCoreService/Upload STREAM_RESP
4 |  REQ:  {
4 |    "instance": {
4 |      "id": 1
4 |    },
4 |    "fqbn": "arduino:mbed_nano:nanorp2040connect",
4 |    "sketch_path": "C:/Users/m.pologruto/Documents/Arduino/sketch_simple",
4 |    "port": {
4 |      "address": "COM3",
4 |      "protocol": "serial"
4 |    },
4 |    "verbose": true
4 |  }
TOUCH: error during reset: opening port at 1200bps: Serial port busy
4 |  RESP: {
4 |    "out_stream": "UGVyZm9ybWluZyAxMjAwLWJwcyB0b3VjaCByZXNldCBvbiBzZXJpYWwgcG9ydCBDT00zCg=="
4 |  }
4 |  RESP: {
4 |    "out_stream": "IkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcQXJkdWlubzE1XHBhY2thZ2VzXGFyZHVpbm9cdG9vbHNccnAyMDQwdG9vbHNcMS4wLjYvcnAyMDQwbG9hZCIgLXYgLUQgIkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcVGVtcFxhcmR1aW5vXHNrZXRjaGVzXEY1NEYxRUNFMTE2RTgzMTk2NzJBMTcyM0QzOUMwOUYwL3NrZXRjaF9zaW1wbGUuaW5vLmVsZiIKcnAyMDQwbG9hZCAxLjAuNiAtIGNvbXBpbGVkIHdpdGggZ28xLjE2LjIKLg=="
4 |  }

What is the new behavior?

The error is displayed on the errStream.

{
  "outStream": "UGVyZm9ybWluZyAxMjAwLWJwcyB0b3VjaCByZXNldCBvbiBzZXJpYWwgcG9ydCBDT00zCg=="
}
{
  "errStream": "Q2Fubm90IHBlcmZvcm0gcG9ydCByZXNldDogVE9VQ0g6IGVycm9yIGR1cmluZyByZXNldDogb3BlbmluZyBwb3J0IGF0IDEyMDBicHM6IFNlcmlhbCBwb3J0IGJ1c3kK"
}
{
  "outStream": "IkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcQXJkdWlubzE1XHBhY2thZ2VzXGFyZHVpbm9cdG9vbHNccnAyMDQwdG9vbHNcMS4wLjYvcnAyMDQwbG9hZCIgLXYgLUQgIkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcVGVtcFxhcmR1aW5vXHNrZXRjaGVzXEY1NEYxRUNFMTE2RTgzMTk2NzJBMTcyM0QzOUMwOUYwL3NrZXRjaF9zaW1wbGUuaW5vLmVsZiIK"
}
{
  "outStream": "cnAyMDQwbG9hZCAxLjAuNiAtIGNvbXBpbGVkIHdpdGggZ28xLjE2LjIKLg=="
}
ERROR:
  Code: Internal
  Message: Failed uploading: uploading error: exit status 1
3 CALLED: /cc.arduino.cli.commands.v1.ArduinoCoreService/Upload STREAM_RESP
3 |  REQ:  {
3 |    "instance": {
3 |      "id": 1
3 |    },
3 |    "fqbn": "arduino:mbed_nano:nanorp2040connect",
3 |    "sketch_path": "C:/Users/m.pologruto/Documents/Arduino/sketch_simple",
3 |    "port": {
3 |      "address": "COM3",
3 |      "protocol": "serial"
3 |    },
3 |    "verbose": true
3 |  }
3 |  RESP: {
3 |    "out_stream": "UGVyZm9ybWluZyAxMjAwLWJwcyB0b3VjaCByZXNldCBvbiBzZXJpYWwgcG9ydCBDT00zCg=="
3 |  }
3 |  RESP: {
3 |    "err_stream": "Q2Fubm90IHBlcmZvcm0gcG9ydCByZXNldDogVE9VQ0g6IGVycm9yIGR1cmluZyByZXNldDogb3BlbmluZyBwb3J0IGF0IDEyMDBicHM6IFNlcmlhbCBwb3J0IGJ1c3kK"
3 |  }
3 |  RESP: {
3 |    "out_stream": "IkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcQXJkdWlubzE1XHBhY2thZ2VzXGFyZHVpbm9cdG9vbHNccnAyMDQwdG9vbHNcMS4wLjYvcnAyMDQwbG9hZCIgLXYgLUQgIkM6XFVzZXJzXG0ucG9sb2dydXRvXEFwcERhdGFcTG9jYWxcVGVtcFxhcmR1aW5vXHNrZXRjaGVzXEY1NEYxRUNFMTE2RTgzMTk2NzJBMTcyM0QzOUMwOUYwL3NrZXRjaF9zaW1wbGUuaW5vLmVsZiIK"
3 |  }
3 |  RESP: {
3 |    "out_stream": "cnAyMDQwbG9hZCAxLjAuNiAtIGNvbXBpbGVkIHdpdGggZ28xLjE2LjIKLg=="
3 |  }
3 |  ERROR:  rpc error: code = Internal desc = Failed uploading: uploading error: exit status 1
3 STREAM CLOSED

Does this PR introduce a breaking change, and is titled accordingly?

No

@MatteoPologruto MatteoPologruto added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: gRPC Related to the gRPC interface labels May 23, 2023
@MatteoPologruto MatteoPologruto self-assigned this May 23, 2023
@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.07 ⚠️

Comparison is base (15a5e88) 62.89% compared to head (b75f29e) 62.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2183      +/-   ##
==========================================
- Coverage   62.89%   62.83%   -0.07%     
==========================================
  Files         220      220              
  Lines       19477    19477              
==========================================
- Hits        12251    12239      -12     
- Misses       6141     6150       +9     
- Partials     1085     1088       +3     
Flag Coverage Δ
unit 62.83% <0.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arduino/serialutils/serialutils.go 68.33% <0.00%> (ø)
commands/upload/upload.go 73.62% <0.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MatteoPologruto MatteoPologruto marked this pull request as ready for review May 23, 2023 11:56
@MatteoPologruto MatteoPologruto merged commit 74dd907 into arduino:master May 31, 2023
@MatteoPologruto MatteoPologruto deleted the grpc-log-error branch May 31, 2023 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gRPC]: Error object contains insufficient info when upload fails due to the busy serial port
2 participants